class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int Min = INT_MAX, ret = 0;
        for(int i = 0; i < prices.size() - 1; ++i)
        {
            Min = min(Min, prices[i]);
            ret = max(ret, prices[i + 1] - Min);
        }
        return ret;
    }
};